﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace GPCSC.Web.CL_USER_S
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				#warning 代码生成提示：显示页面,请检查确认该语句是否正确
				ShowInfo();
			}
		}
			
	private void ShowInfo()
	{
		GPCSC.BLL.CL_USER_S bll=new GPCSC.BLL.CL_USER_S();
		GPCSC.Model.CL_USER_S model=bll.GetModel();
		this.lblCL_USER_SOID.Text=model.CL_USER_SOID.ToString();
		this.txtUSERNAME.Text=model.USERNAME;
		this.txtPWD.Text=model.PWD;
		this.txtREALNAME.Text=model.REALNAME;
		this.txtREMARK.Text=model.REMARK;
		this.lblCL_DepartID_PK.Text=model.CL_DepartID_PK.ToString();
		this.txtDepartName.Text=model.DepartName;
		this.lblCL_POSTID_PK.Text=model.CL_POSTID_PK.ToString();
		this.txtPOSTName.Text=model.POSTName;
		this.txtcreates.Text=model.creates.ToString();
		this.txtTEL.Text=model.TEL;
		this.txtENABLED.Text=model.ENABLED.ToString();
		this.txtUrlImage.Text=model.UrlImage;
		this.txtLoginTime.Text=model.LoginTime.ToString();
		this.lblPD_CompanyInfoSOID_PK.Text=model.PD_CompanyInfoSOID_PK.ToString();
		this.txtPD_CompanyName.Text=model.PD_CompanyName;
		this.txtidenID.Text=model.idenID;
		this.txtContact.Text=model.Contact;
		this.txtE_mail.Text=model.E_mail;
		this.txtstate.Text=model.state;
		this.lblCL_ROLEOID_PK.Text=model.CL_ROLEOID_PK.ToString();
		this.txtCL_ROLEname.Text=model.CL_ROLEname;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtUSERNAME.Text.Trim().Length==0)
			{
				strErr+="USERNAME不能为空！\\n";	
			}
			if(this.txtPWD.Text.Trim().Length==0)
			{
				strErr+="PWD不能为空！\\n";	
			}
			if(this.txtREALNAME.Text.Trim().Length==0)
			{
				strErr+="REALNAME不能为空！\\n";	
			}
			if(this.txtREMARK.Text.Trim().Length==0)
			{
				strErr+="REMARK不能为空！\\n";	
			}
			if(this.txtDepartName.Text.Trim().Length==0)
			{
				strErr+="DepartName不能为空！\\n";	
			}
			if(this.txtPOSTName.Text.Trim().Length==0)
			{
				strErr+="POSTName不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtcreates.Text))
			{
				strErr+="creates格式错误！\\n";	
			}
			if(this.txtTEL.Text.Trim().Length==0)
			{
				strErr+="TEL不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtENABLED.Text))
			{
				strErr+="ENABLED格式错误！\\n";	
			}
			if(this.txtUrlImage.Text.Trim().Length==0)
			{
				strErr+="UrlImage不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtLoginTime.Text))
			{
				strErr+="LoginTime格式错误！\\n";	
			}
			if(this.txtPD_CompanyName.Text.Trim().Length==0)
			{
				strErr+="PD_CompanyName不能为空！\\n";	
			}
			if(this.txtidenID.Text.Trim().Length==0)
			{
				strErr+="idenID不能为空！\\n";	
			}
			if(this.txtContact.Text.Trim().Length==0)
			{
				strErr+="Contact不能为空！\\n";	
			}
			if(this.txtE_mail.Text.Trim().Length==0)
			{
				strErr+="E_mail不能为空！\\n";	
			}
			if(this.txtstate.Text.Trim().Length==0)
			{
				strErr+="state不能为空！\\n";	
			}
			if(this.txtCL_ROLEname.Text.Trim().Length==0)
			{
				strErr+="CL_ROLEname不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			Guid CL_USER_SOID= new Guid(this.lblCL_USER_SOID.Text);
			string USERNAME=this.txtUSERNAME.Text;
			string PWD=this.txtPWD.Text;
			string REALNAME=this.txtREALNAME.Text;
			string REMARK=this.txtREMARK.Text;
			Guid CL_DepartID_PK= new Guid(this.lblCL_DepartID_PK.Text);
			string DepartName=this.txtDepartName.Text;
			Guid CL_POSTID_PK= new Guid(this.lblCL_POSTID_PK.Text);
			string POSTName=this.txtPOSTName.Text;
			DateTime creates=DateTime.Parse(this.txtcreates.Text);
			string TEL=this.txtTEL.Text;
			int ENABLED=int.Parse(this.txtENABLED.Text);
			string UrlImage=this.txtUrlImage.Text;
			DateTime LoginTime=DateTime.Parse(this.txtLoginTime.Text);
			Guid PD_CompanyInfoSOID_PK= new Guid(this.lblPD_CompanyInfoSOID_PK.Text);
			string PD_CompanyName=this.txtPD_CompanyName.Text;
			string idenID=this.txtidenID.Text;
			string Contact=this.txtContact.Text;
			string E_mail=this.txtE_mail.Text;
			string state=this.txtstate.Text;
			Guid CL_ROLEOID_PK= new Guid(this.lblCL_ROLEOID_PK.Text);
			string CL_ROLEname=this.txtCL_ROLEname.Text;


			GPCSC.Model.CL_USER_S model=new GPCSC.Model.CL_USER_S();
			model.CL_USER_SOID=CL_USER_SOID;
			model.USERNAME=USERNAME;
			model.PWD=PWD;
			model.REALNAME=REALNAME;
			model.REMARK=REMARK;
			model.CL_DepartID_PK=CL_DepartID_PK;
			model.DepartName=DepartName;
			model.CL_POSTID_PK=CL_POSTID_PK;
			model.POSTName=POSTName;
			model.creates=creates;
			model.TEL=TEL;
			model.ENABLED=ENABLED;
			model.UrlImage=UrlImage;
			model.LoginTime=LoginTime;
			model.PD_CompanyInfoSOID_PK=PD_CompanyInfoSOID_PK;
			model.PD_CompanyName=PD_CompanyName;
			model.idenID=idenID;
			model.Contact=Contact;
			model.E_mail=E_mail;
			model.state=state;
			model.CL_ROLEOID_PK=CL_ROLEOID_PK;
			model.CL_ROLEname=CL_ROLEname;

			GPCSC.BLL.CL_USER_S bll=new GPCSC.BLL.CL_USER_S();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
